#ifndef DATABASEACCESSOR_HPP
#define DATABASEACCESSOR_HPP

#include <QString>
#include <QSqlDatabase>
#include <QObject>

#include "Client.hpp"

class DataBaseAccessor : public QObject
{
    Q_OBJECT
public:
    static DataBaseAccessor* instance();
    bool connect(QString& hostName, QString& dbName,
                 QString& userName, QString& userPassword);
    bool addUser(QString& userLogin, QString& userPassword, USER_RIGHT right);
    void getList();
    unsigned long long loginUser(QString& userLogin, QString& userPassword);



private:
    DataBaseAccessor();
    DataBaseAccessor(const DataBaseAccessor&);
    DataBaseAccessor& operator = (const DataBaseAccessor&);

    static DataBaseAccessor* m_instance;

    QSqlDatabase m_db;

public slots:
    void execQuery(QString& query, qint32 socket);

signals:
    //callback(QSqlQuery query, qint32 socket);
};

inline DataBaseAccessor* dataBaseInstance()
{
    return DataBaseAccessor::instance();
}

#endif // DATABASEACCESSOR_HPP
